﻿<?php

class vMenu
{
	public static function Generate($pages, $current_page_code, $title)
	{
		$html = '<div class="navbar navbar-fixed-top">';
      	$html .= '<div class="navbar-inner">';
        $html .= '<div class="container">';
        $html .= '<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">';
        $html .= '<span class="icon-bar"></span>';
        $html .= '<span class="icon-bar"></span>';
        $html .= '<span class="icon-bar"></span>';
        $html .= '</a>';
        $html .= '<a class="brand" href="#">'.$title.'</a>';
        $html .= '<div class="nav-collapse collapse">';
        $html .= '<ul class="nav">';

		// Logger::log("menu.generate", print_r($pages, true));

		foreach ($pages as $page) {
			// $html .= '<a href="index.php?page='.$page[2].'" class="top-menu-item">'.$page[3].'</a>';
			$active = ($page['code'] == $current_page_code) ? ' class="active"' : '';
			$html .= '<li'.$active.'><a href="index.php?page='.$page['code'].'" class="top-menu-item">'.$page['title'].'</a></li>';
		}
        $html .= '</ul>';
        $html .= '<ul class="nav pull-right">';
        $html .= '<li>';
        $html .= '<a href="index.php?logout">Выход</a>';
        $html .= '</li>';
        $html .= '</ul>';
        $html .= '</div>';
        $html .= '</div>';
      	$html .= '</div>';
    	$html .= '</div>';

		return $html;
	}
}